package com.ljm.boot.rabbitmq.producer;

import com.ljm.boot.rabbitmq.constant.*;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 消息发送者
 */
@Service
public class TopicProducer {

    @Resource
    private RabbitTemplate rabbitTemplate;

    public void sendTopic1(Object msg) {
        rabbitTemplate.convertAndSend(RabbitMQConstant.TOPIC_EXCHANGE, "queue.red.message", msg);
    }

    public void sendTopic2(Object msg) {
        rabbitTemplate.convertAndSend(RabbitMQConstant.TOPIC_EXCHANGE, "green.queue.green.message", msg);
    }

}
